package com.heima.behavior.controller;

import com.heima.behavior.pojos.LikesBehaviorDto;
import com.heima.behavior.pojos.UnLikesBehaviorDto;
import com.heima.behavior.service.BehaviorService;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户行为管理接口
 */
@Slf4j
@RestController
@RequestMapping("/api/v1")
public class BehaviorController {

    @Autowired
    private BehaviorService behaviorService;

    /**
     * 用户点赞
     * @param dto
     * @return
     */
    @PostMapping("/likes_behavior")
    public ResponseResult likesBehavior(@RequestBody LikesBehaviorDto dto){
        log.info("用户点赞操作{}",dto);
        return behaviorService.likesBehavior(dto);
    }

    /**
     * 阅读
     * @param dto
     * @return
     */
    @PostMapping("/read_behavior")
    public ResponseResult readBehavior(@RequestBody LikesBehaviorDto dto){
        log.info("用户阅读操作{}",dto);
        return behaviorService.readBehavior(dto);
    }

    /**
     * 不喜欢
     * @param dto
     * @return
     */
    @PostMapping("/un_likes_behavior")
    public ResponseResult unLikesBehavior(@RequestBody UnLikesBehaviorDto dto){
        log.info("用户不喜欢操作{}",dto);
        return behaviorService.unLikesBehavior(dto);
    }
}
